package com.interview.ujiuye2;

import java.io.*;

//1. 实现Serializable接口
public class Employee implements Serializable {
	private String name;
	private Integer age;
	private Double salary;


	public static void main(String[] args)  throws Exception{
		ObjectInputStream ois = new ObjectInputStream(new FileInputStream("emp.data"));
		Employee o =(Employee) ois.readObject();
		System.out.println(o.getName());
		System.out.println(o.getAge());
		System.out.println(o.getSalary());
	}

	private static void test1() throws IOException {
		Employee employee = new Employee("迪丽热巴",29,8000d);
		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("emp.data"));
		oos.writeObject(employee);
		oos.close();
	}


	public Employee(String name, Integer age, Double salary) {
		super();
		this.name = name;
		this.age = age;
		this.salary = salary;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getAge() {
		return age;
	}
	public void setAge(Integer age) {
		this.age = age;
	}
	public Double getSalary() {
		return salary;
	}
	public void setSalary(Double salary) {
		this.salary = salary;
	}
	@Override
	public String toString() {
		return "Employee [name=" + name + ", age=" + age + ", salary=" + salary + "]";
	}
}